<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图片遍历</title>
    <style>
        div{
        }
    </style>
</head>
<body>
       <div id="box">
       </div>

        <script>
            var img = [
                {url:'img/1.jpg',title:'呆萌', alt:'图片' ,whitch:'250px',height:'200px'},
                {url:'img/2.jpg',title:'性感', alt:'图片' ,whitch:'250px',height:'200px'},
                {url:'img/3.png',title:'开朗', alt:'图片' ,whitch:'250px',height:'200px'},
                {url:'img/4.png',title:'阳光', alt:'图片' ,whitch:'250px',height:'200px'}
            ];
            var s = '';
            for(var i = 0;i<img.length;i++){
                s = s +' <img src="'+img[i].url+'"title="'+img[i].title+'" alt="'+img[i].alt+'" style="width: '+img[i].whitch+';height: '+img[i].height+'">'
            }
            console.log(s);
            boxObj = document.getElementById('box');
            boxObj.innerHTML = s
        </script>
</body>
</html>





